package cn.yunhe.util;


import cn.yunhe.entity.Field;
import cn.yunhe.entity.Question;
import cn.yunhe.entity.QuestionType;

import java.util.Date;
import java.util.List;


/**
 * List 转 Question
 * @Author liu
 */
public class ListToQuestionUtil {

    public static Question getQuestion(List<String> list ,Integer fieldId,String creator){
            Question question=new Question();
            if (fieldId!=null){
                Field field=new Field();
                field.setFieldId(fieldId);
                question.setField(field);
            }
            int i=1;
            for (String str:list) {
                switch (i){
                    case 1:
                        question.setName(str);
                        break;
                    case 2:
                        question.setA(str);
                        break;
                    case 3:
                        question.setB(str);
                        break;
                    case 4:
                        question.setC(str);
                        break;
                    case 5:
                        question.setD(str);
                        break;
                    case 6:
                        question.setQuestionType(new QuestionType(QuestionTypeUtil.getQuestionType(str)));
                        System.out.println(question.getQuestionType().getId()+"==========");
                        question.setAnswer(str);
                        break;
                }
                i++;
            }
            question.setCreateTime(new Date());
            question.setCreator(creator);
        return question;
    }
}
